fun List<String>.combine(): String = mapIndexed { i, s -> i.toString() + s }.joinToString(", ")
| Function Call | Return Value | |||
|---|---|---|---|---|
| listOf("a").combine() | → | |||
| listOf("a", "b", "c", "d").combine() | → | |||
Experiment with this code on Gitpod.io or as a Kotlin Playground